Centralized exchanges (CEXs) currently dominate the cryptocurrency trading landscape due to their speed, liquidity, and ease of use. However, they also introduce several critical risks, including custodianship of user assets, vulnerability to censorship, and reliance on centralized infrastructure that represents a single point of failure. In contrast, the advent of Automated Market Makers (AMMs), such as Uniswap, brought a paradigm shift in decentralized finance (DeFi) by enabling peer-to-peer trading through liquidity pools without intermediaries. While revolutionary, AMMs face inherent limitations such as slippage, impermanent loss for liquidity providers, and suboptimal price discovery compared to traditional orderbook systems. This research proposes a decentralized on-chain orderbook model designed to bridge the gap between centralized exchanges and AMM-based decentralized exchanges. The system replicates the precision, transparency, and efficiency of traditional orderbook-driven markets while adhering to DeFi principles of trustlessness and non-custodial asset management. Developed using Solidity smart contracts and deployed on Ethereum-compatible test networks such as Monad the platform enables users to place, cancel, and execute both limit and market orders directly on-chain. To address blockchain performance bottlenecks, the architecture incorporates an off-chain order matcher that listens to smart contract events, identifies compatible buy and sell orders, and batches potential matches for improved gas efficiency. Importantly, final trade execution and settlement remain fully decentralized, being handled exclusively by smart contracts. This hybrid design achieves low-latency order matching without compromising decentralization or asset security.
Introduction
This project introduces a hybrid decentralized exchange (DEX) that combines:
The speed and efficiency of centralized exchanges (CEXs) like Coinbase
The security and user control of decentralized systems
Unlike CEXs, users retain custody of their funds at all times. Unlike traditional DEXs (like Uniswap), this system offers:
An on-chain orderbook for transparency and control
An off-chain matching engine for fast and efficient trade execution
Fully on-chain settlement, enforced by smart contracts
2. Problem & Motivation
CEXs are fast but require trust (custodianship, freezing risk)
AMMs (e.g., Uniswap) enable decentralized trading but suffer from:
Slippage
Impermanent loss
High gas fees
Limited support for complex trades
Hybrid DEXs (e.g., Loopring, dYdX) improve performance but compromise decentralization due to semi-centralized components
This project aims to eliminate these trade-offs.
3. Research Objective
Build a fully decentralized, high-performance on-chain orderbook system
Ensure fairness, transparency, and security without intermediaries
Achieve speed and efficiency using:
Smart contracts for trade execution and fund custody
An off-chain matcher to reduce gas costs
Provide a user-friendly interface with real-time data and charts, suitable for both crypto-native and traditional traders
4. Literature Review Highlights
Model
Strengths
Weaknesses
AMMs (e.g., Uniswap, Curve)
Decentralized, permissionless
Slippage, impermanent loss, inefficient capital usage
Fully decentralized orderbooks still underexplored
5. Proposed Architecture
Smart Contracts (Solidity on Ethereum testnets):
Vault: Securely holds and manages user funds
Orderbook: Records and manages limit/market orders on-chain
Pair Registry: Maintains valid trading pairs
Fee Manager: Computes and distributes trading fees
Off-Chain Matcher:
Listens to blockchain events
Matches buy/sell orders off-chain
Submits matches on-chain for execution (preserving decentralization)
Frontend (React.js + Tailwind CSS):
Connects wallets
Displays real-time orderbooks and charts
Enables intuitive trade placement and monitoring
6. Results & Evaluation
Performance:
10–15 transactions/sec, significantly faster than full on-chain systems
30–40% lower gas costs (50k–70k units per trade)
Minimal slippage, improved price discovery and capital efficiency
Usability:
Clean and intuitive interface
Live updates via WebSocket
Comfortable experience even for novice users
Security & Trust:
All funds stay in user custody
Trade execution is fully transparent on-chain
Prevents front-running and other unfair trading practices
Conclusion
This project set out to design and implement a decentralized orderbook system that brings the precision of traditional exchanges into the blockchain space. By combining Solidity smart contracts with an off-chain event listener for order matching, the system allows users to place, cancel, and execute trades directly on-chain while maintaining gas efficiency. Compared to AMM-based DEXs, the on-chain orderbook provides better capital efficiency, transparent price discovery, and execution quality closer to centralized exchanges. At the same time, challenges like scalability, front-running resistance, and transaction costs were carefully addressed through design decisions such as batched settlement and efficient data structures. The frontend, built with React and ethers.js, makes interaction seamless for users, while integration with the Pair Registry and Vault contracts ensures secure custody and role-based management. Testing confirmed that deposits, withdrawals, and trade settlement function as expected, demonstrating the feasibility of bringing orderbook models into decentralized finance.
In conclusion, this system shows that on-chain orderbooks are a viable alternative to AMMs for certain markets, bridging the gap between traditional finance mechanisms and decentralized principles. It opens the door for further improvements in scalability through L2 solutions, enhanced matching engines, and more advanced order types in future work. While this project has successfully demonstrated a functional on-chain orderbook, there remain several promising directions for future development and optimization. One of the major challenges lies in scalability, as high gas costs and latency on mainnet Ethereum limit throughput. To address this, future iterations can integrate Layer-2 solutions such as Arbitrum, Optimism, or zkSync. These platforms offer significantly faster and cheaper transactions while maintaining the decentralization guarantees of Ethereum.
Another area of improvement is the introduction of advanced order types. At present, the system supports only basic limit and market orders. Expanding this to include stop-loss, take-profit, iceberg, and other conditional orders would bring the functionality closer to what centralized exchanges currently offer, thereby attracting a wider user base. The matching engine also presents opportunities for enhancement. The current design is deliberately minimalistic, prioritizing simplicity and clarity. However, a more sophisticated off-chain matching engine, supplemented by cryptographic proofs to ensure fairness, could dramatically improve execution speed while still preserving trustlessness.
References
[1] Buterin, V. (2019). The limits of decentralized order books on Ethereum. Ethereum Foundation Blog.
[2] Loopring Foundation. (2021). Loopring Protocol Design: Whitepaper.
[3] Adams, H., Zinsmeister, N., Salem, M., Robinson, D., & Hayden, N. (2021). Uniswap v3 Core: Whitepaper. Uniswap Labs.
[4] Ethereum Foundation. (2024). Solidity Documentation.
[5] Wood, G. (2014). Ethereum: A secure decentralised generalised transaction ledger. Ethereum Project Yellow Paper, 151.
[6] Brownlee, J. (2017). Machine Learning Mastery.
[7] dYdX Trading Inc. (2020). dYdX Protocol: A Decentralized Perpetuals Exchange, Whitepaper.
[8] Binance Research. (2021). Decentralized Finance (DeFi): On-chain Order Books vs. AMMs. Research Report.
[9] Paradigm Research. (2021). The Evolution of Decentralized Exchanges. Paradigm Research Report.
[10] StarkWare Industries. (2020). ZK-Rollups: Scaling Decentralized Exchanges. Technical Paper.
[11] Egorov, M. (2020). Curve Finance: StableSwap Whitepaper.
[12] Kiayias, A., Russell, A., David, B., & Oliynykov, R. (2017). Ouroboros: A Provably Secure Proof-of-Stake Blockchain Protocol. In Advances in Cryptology – CRYPTO 2017. Springer.
[13] Flashbots. (2021). MEV: Mitigating Miner Extractable Value. Research Report.
[14] ConsenSys. (2021). The State of Decentralized Exchanges (DEXs). ConsenSys Research.
[15] Zhang, M., Xie, Y., Xu, H., & Song, D. (2022). DeFiRanger: Detecting Price Manipulation Attacks on DeFi Applications. In Proceedings of the IEEE Symposium on Security and Privacy (SP) (pp. 2440–2457). IEEE.